package com.landlord.project;

import java.util.ArrayList;
import java.util.List;

public class Farmer {
    private static LandlordServer ls = null;
    private List<LandlordData> list = null;
    //编号
    private int id;
    //昵称
    private String name;
    //豆子数
    private long number=30000;
    //胜率
    private double rate;
    //对局数
    private int num;
    //最高连胜
    private int maxwin;
    //炸弹数
    private int numbomb;
    //春天
    private int spring;
    //是否出牌
    private boolean cardprint;

    private Farmer(int id, String name) {
        this.id = id;
        this.name = name;
    }

    private static Farmer p1 = null;
    private static Farmer p2 = null;
    private static Farmer p3 = null;

    private static Farmer[] p = new Farmer[3];

    public static Farmer[] getFarmer(){
        if (p1==null){
            p1 = new Farmer(0,"玩家一");
            p[0] = p1;
        }
        if (p2==null){
            p2 = new Farmer(1,"玩家二");
            p[1] = p2;
        }
        if (p3==null){
            p3 = new Farmer(2,"玩家三");
            p[2] = p3;
        }
        return p;
    }

    //返回玩家的牌
    public List<LandlordData> getList() {
        if (list==null){
            list = new ArrayList<>(20);
        }
        return list;
    }

    //返回地主编号
    public static int randomLandlord(){
        return (int)(Math.random()*3);
    }

    //返回棋牌对象
    public static LandlordServer getLs() {
        if (ls==null){
            ls = new LandlordServer();
        }
        return ls;
        //多次
//        return new LandlordServer();
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }


    public long getNumber() {
        return number;
    }

    public void setNumber(long number) {
        this.number = number;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public int getMaxwin() {
        return maxwin;
    }

    public void setMaxwin(int maxwin) {
        this.maxwin = maxwin;
    }

    public int getNumbomb() {
        return numbomb;
    }

    public void setNumbomb(int numbomb) {
        this.numbomb = numbomb;
    }

    public int getSpring() {
        return spring;
    }

    public void setSpring(int spring) {
        this.spring = spring;
    }

    public boolean isCardprint() {
        return cardprint;
    }

    public void setCardprint(boolean cardprint) {
        this.cardprint = cardprint;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id:" + id +
                ", 昵称:" + name +
                ", 豆子数:" + number +
                ", 胜率:" + rate*100+"%" +
                ", 对局数:" + num +
                ", 最高连胜:" + maxwin +
                ", 炸弹数:" + numbomb +
                ", 春天:" + spring +
                '}';
    }
}
